const USERTEST = {
  'uuid': '52fea788dfae4e6b849335fa9633f913',
  'gender': 1,
  'uid': 52,
  'isVip': 0,
  'ticket': '4UMW9008XEPSCLSMC7E1',
  'vipExpireDate': '',
  'isValidated': 1,
  'isThird': 1,
  'vipTips': '开通会员免费看大片',
  'avatar': 'https:\/\/eximg.hitv.com\/1\/mava1_it8sHCPwxhRYgDPKokck7nTtnw2SzPb0.jpg',
  'birthday': '1970-01-01',
  'isRenew': 0,
  'relateMobile': '15521823519',
  'isMobile': 0,
  'vipLevel': 0,
  'nickname': '宋航有史以来了',
  'vipExpiretime': '',
  'vipInfo': {
    'vipIcon': 'https:\/\/i5.hitv.com\/s1\/2017\/member\/images\/i552b8d8e8b5da.png',
    'showVipIcon': 1,
    'notVipIcon': '',
    'showVipDesc': 0
  }
}
const DEVETEST = {
  'osVersion': '11.3',
  'gps': '',
  'ch': 'appstore',
  'time': '20180330113815',
  'did': '2d878f32e2390601879b78052d5130131c6990da',
  'guid': '978102833373384704',
  'mf': 'Apple',
  'channel': 'AppStore',
  'appVersion': '5.7.6',
  'uuid': '52fea788dfae4e6b849335fa9633f913',
  'rch': '',
  'sver': 'iphone-11.3',
  'ticket': 'OJMW8377XATNDUEP3F60',
  'isdebug': 0,
  'IMEI': '',
  'aver': 'imgotv-iphone-5.7.6',
  'cid': '22fff4bf1b83b88d79debb9c7217ca7b',
  'net': 1,
  'sid': '4FECCAF7-DE68-4FD6-B9DE-3A4FFAA4914F',
  'mac': '2d878f32e2390601879b78052d5130131c6990da',
  'mod': 'iPhone10_3',
  'rdc': '',
  'abroad': '0',
  'appBuildVersion': '5.7.6.1803142',
  'p2p': '1',
  'dname': '%E5%AE%8B%E8%88%AA',
  'reviewStatus': '0',
  'osType': 'ios',
  'Android_ID': '',
  'device': 'iPhone',
  'idfa': '697515E0-382F-4FF3-ADC2-AE415B214A2A'
}
const getUserInfo = function () {
  return new Promise((resolve, reject) => {
    if (__DEV__) {
      resolve(USERTEST)
    }
    else {
      if (MgtvApi) {
        MgtvApi.getUserInfo(function (res) {
          console.log('获取用户信息')
          console.log(res)
          if (res) {
            res = JSON.parse(res)
            if (res.uuid || res.uuid !== '') {
              resolve(res)
            }
            else {
              resolve(null)
            }
          }
          else {
            resolve(null)
          }
        })
      }
    }
  })
}
const login = function () {
  return new Promise((resolve, reject) => {
    if (__DEV__) {
      resolve(USERTEST)
    }
    else {
      if (MgtvApi) {
        MgtvApi.login(function (res) {
          console.log('登录')
          console.log(res)
          if (res) {
            res = JSON.parse(res)
            if (res.uuid || res.uuid !== '') {
              resolve(res)
            }
          }
          else {
            resolve(null)
          }
        })
      }
    }
  })
}
const getDeviceInfo = function () {
  return new Promise((resolve, reject) => {
    if (__DEV__) {
      resolve(DEVETEST)
    }
    else {
      if (MgtvApi) {
        MgtvApi.getDeviceInfo(function (res) {
          console.log('获取硬件信息')
          console.log(res)
          if (res || res !== '') {
            res = JSON.parse(res)
            resolve(res)
          }
          else {
            resolve(null)
          }
        })
      }
    }
  })
}

export {
  getUserInfo,
  login,
  getDeviceInfo
}
